package com.ruoyi.activity.controller.portal;

import com.ruoyi.activity.domain.Works;
import com.ruoyi.activity.domain.WorksDetail;
import com.ruoyi.activity.req.PortalWorksListReq;
import com.ruoyi.activity.req.ReviewWorkReq;
import com.ruoyi.activity.req.WorksListReq;
import com.ruoyi.activity.req.WorksSignReq;
import com.ruoyi.activity.service.IWorksService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * 作品模块
 *
 * @author wxc
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/portal/works")
public class PortalWorksController {
    @Autowired
    private IWorksService worksService;
    /**
     * 报名或修改，上传参赛作品
     */
    @PostMapping("/sign")
    public R sign(@RequestBody WorksSignReq worksSignReq) {
        String message = worksService.sign(worksSignReq);
        return R.ok(message);
    }
    /**
     * 查询参赛作品，查询条件为“作品名称”和“状态”
     */
    @PostMapping("/list")
    public R info(@RequestBody WorksListReq works) {
        startPage();
        List<Works> list = worksService.selectWorksList(works);
        return R.ok(list);
    }
    /**
     * 点击“评分”进入详情页面查看
     */
    @GetMapping("/{id}")
    public R info(@RequestBody Long id) {
        WorksDetail worksDetail = worksService.selectWorksDetailById(id);
        return R.ok(worksDetail);
    }

}
